<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>BBS首页</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .btn-custom {
            margin-right: 10px;
            padding: 10px 20px;
            font-size: 16px;
        }
        .card {
            transition: transform 0.2s;
        }
        .card:hover {
            transform: scale(1.02);
        }
        .card-title a {
            text-decoration: none;
            color: #333;
        }
        .card-title a:hover {
            color: #007bff;
        }
    </style>
</head>
<body>
<div class="container mt-5">
    <h1 class="text-center mb-4">欢迎来到BBS论坛</h1>
    <div class="text-center mb-5">
        <a th:href="@{/user/info}" class="btn btn-success btn-custom">
            <i class="fas fa-user mr-1"></i> 个人信息
        </a>
        <a th:href="@{/user/index/1}" class="btn btn-primary btn-custom">
            <i class="fas fa-list mr-1"></i> 查看帖子列表
        </a>
        <a th:href="@{/user/post}" class="btn btn-info btn-custom">
            <i class="fas fa-edit mr-1"></i> 发布新帖子
        </a>
    </div>
    <div class="row">
        <div class="col-md-8">
            <h2 class="mb-4">最新帖子</h2>
            <div th:each="item : ${latestPosts}">
                <div class="card mb-3">
                    <div class="card-body">
                        <h5 class="card-title">
                            <a th:href="@{/user/post/detail/{contextId}(contextId=${item.id})}" th:text="${item.title}"></a>
                        </h5>
                        <p class="card-text" th:text="${item.context}"></p>
                        <small class="text-muted">作者：[[${item.userId}]] | 发布时间：[[${#temporals.format(item.createTime, 'yyyy-MM-dd HH:mm')}]]</small>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <h2 class="mb-4">热门帖子</h2>
            <div th:each="item : ${hotPosts}">
                <div class="card mb-3">
                    <div class="card-body">
                        <h5 class="card-title">
                            <a th:href="@{/user/post/detail/{contextId}(contextId=${item.id})}" th:text="${item.title}"></a>
                        </h5>
                        <small class="text-muted">作者：[[${item.userId}]] | 发布时间：[[${#temporals.format(item.createTime, 'yyyy-MM-dd HH:mm')}]]</small>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>